﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CPETwit.Web.Service.Implementation;
using CPETwit.Web.Service.Interface;
using CPETwit.Data.Entity;


namespace CPETwit.Web.CustomClass
{
    public class CustomTweetProvider
    {
        public IEnumerable<CustomTweet> getCustomTweet(User u){
            ITwitterService twitterService = new TwitterService();
            IEnumerable<CPETwit.Data.Entity.Tweet> listeTweets = twitterService.GetUserTimeline(u);
            List<CustomTweet> listeCustomTweets = new List<CustomTweet>();
            foreach (var currentTweet in listeTweets)
            {
                CustomTweet customTweet = new CustomTweet();
                customTweet.originalUser = twitterService.GetTweetOwner(currentTweet).FirstOrDefault() ;
                customTweet.tweet = currentTweet;
                listeCustomTweets.Add(customTweet);
            }

            return listeCustomTweets;
        }
    }
}